/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.dizucar.convertidor;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import sv.com.dizucar.controlador.CajeroControlador;
import sv.com.dizucar.modelo.Cajero;

/**
 *
 * @author stefanny
 */
@FacesConverter(forClass=Cajero.class)
public class CajeroConvertidor implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) { 
        CajeroControlador controlador = new CajeroControlador();
        Integer id = Integer.parseInt(value);
        return controlador.encontrarEntidad(id);
        
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
       return ((Cajero) value).getIdcajero().toString();
    }
    
    
}
